const {exec} = require('../db/mysql')
const {genPassword} = require('../utils/crypto')
const login = (username,password) => {
    username = escape(username)
    password = escape(password)
    //加密密码
    password = genPassword(password)
    // select username, realname from user where username = 'lisi%27%20--%20%27' and pwd = '456'
    const sql = `select username,realname from user where username='${username}' and pwd='${password}'`
    console.log(sql);
    return exec(sql).then(rows => {
       return rows[0] || {} 
    })
}
module.exports = {
    login
}